
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script>
var num = 0.007;//要四舍五入的数字  
var fixNum = new Number(num+1).toFixed(2);// 1.01 四舍五入之前加1  
var fixedNum = new Number(fixNum - 1).toFixed(2);// 0.01 四舍五入之后减1，再四舍五入一下  
alert(fixedNum);// 0.01




Number.prototype.toFixed=function(len) {
	var add = 0;
	var s,temp;
	var s1 = this + "";
	var start = s1.indexOf(".");
	if(s1.substr(start+len+1,1)>=5)add=1;
	var temp = Math.pow(10,len);
	s = Math.floor(this * temp) + add;
	return s/temp;
}

console.log(num.toFixed(2));
</script>
</html>
